/** 
 * 自定义JS函数
 * */
 
//var domain = 'http://vqz.jiuge_mc.com'; //本地域名
//var domain = 'http://vqz.fuzhuangchangongxiao.cn'; //云端域名
var domain = '';
var appAccess = 'qSoiKwpWVge4TkaryH6MKvOdceGt7ZMaF20g8H0cnXI'; //APP接口权限
var headers = { //请求headers
	'Content-Type':'application/x-www-form-urlencoded' ,
};
var timeout = 10*1000; //请求延时秒数
var videoRadio = 1.7777;
var userInfoKey = 'userInfoKey'; //用户信息





/**
 * 一级菜单
 * */
function getFootMenus(key){
	if (key==1) {
		mui('#refresh')[0].innerHTML = '';
	}
	var menus = [
		{},
		{
			'title':'首页',
			'icon':'mui-icon-home',
			'jsfun':'jumpToIndex()',
		},
		{
			'title':'特效',
			'icon':'mui-icon-pengyouquan',
			'jsfun':'jumpToWay()',
		},
		{
			'title':'共享',
			'icon':'mui-icon-chatboxes',
			'jsfun':'jumpToTalk()',
		},
		{
			'title':'我',
			'icon':'mui-icon-contact',
			'jsfun':'jumpToMy()',
		},
	];
	var m = '';
	for (var i=1;i<menus.length;i++) {
		var title = menus[i].title;
		var icon = menus[i].icon;
		var jsfun = menus[i].jsfun;
		m += '<a class="mui-tab-item';
		m += i==key ? ' mui-active' : '';
		m += '" onclick="'+jsfun+'">';
		m += '<span class="mui-icon '+icon+'"></span>';
		m += '<span class="mui-tab-label">'+title+'</span>';
		m += '</a>';
		m += '';
	}
	mui('#footMenu')[0].innerHTML = m;
	mui('#footMenu')[0].style.height = '65px';
}
/**
 * 一级页面
 * */
function jumpToIndex(){ //视频
	window.location.href = 'index.html';
}
function jumpToWay(){ //特效
	window.location.href = 'way.html';
}
function jumpToTalk(){ //分享
	window.location.href = 'talk.html';
}
function jumpToMy(){ //我
	window.location.href = 'my.html';
}


/** 
 * 缓存处理
 * */
//缓存获取
function cacheGet(key){
	var cacheStr = localStorage.getItem(key);
	var cache = JSON.parse(cacheStr);
	return cache;
}
//缓存设置
function cacheSet(key,val){
	//把数组转换为对象存入
	var str = JSON.stringify(val);
	localStorage.setItem(key,str);
	return true;
}
//缓存删除
function cacheDel(key){
    localStorage.removeItem(key);
}
//缓存删除
function cacheClear(){
    localStorage.clear();
}
 

/**
 * URL中，获取指定参数
 * paramName URL中需要获取的参数键名
 * */
function getUrlParam(paramName) {
    var url = document.location.toString();
    var arrObj = url.split("?");
    if (arrObj.length > 1) {
        var arrParam = arrObj[1].split("&");
        var arr;
        for (var i = 0; i < arrParam.length; i++) {
            arr = arrParam[i].split("=");
            if (arr != null && arr[0] == paramName) {
                return decodeURI(arr[1]);
            }
        }
        return "";
    }
    else {
        return "";
    }
}


/** 
 * 用js限制字数，超出部分以省略号...显示
 * str 字符串
 * num 显示的字数
 * */
function getStrLimitNum(str,num) {
    var strNew = '';
	if (str.length <= num) {
		strNew = str;
	} else {
		strNew = str.substr(0,num) + '...' ;
	}
	return strNew;
}


/** 
 * 获取数字随机值
 * min最小值, max最大值
 * */
 function getRandomInt(min,max){
	return Math.floor(Math.random()*(max-min+1))+min;
 }
 

 /** 
  * 获取数据缓存
  * key 缓存键名
  * */
 function getListCache(key){
 	var resList = cacheGet(key);
 	if (!resList) {
 		var list = new Array(),  //数据数组
 			idstring = ''; //ID字符串集合
 		return {
 			// 数据数组
 			list: list,
 			// 历史ID集合
 			idstr: idstring
 		};
 	}
 	return resList;
 }
 /** 
  * 设置数据缓存
  * key 缓存的键名
  * item 新数据对象一个
  * */
 function setListCache(key, item){
 	var resList = getListCache(key);
 	var list = resList.list,  //数据数组
 		idstring = resList.idstr; //历史ID字符串集合
 	if (list.length==0) {
 		idstring = item.id;
 	} else {
 		idstring = idstring+','+item.id;
 	}
 	list[list.length] = item;
 	var listNew = {
 		// 数据数组
 		list: list,
 		// 历史ID字符串集合
 		idstr: idstring,
 	};
 	cacheSet(key, listNew);
 }


// MUI后退
mui.back = function () {
	mui('#refresh')[0].innerHTML = '';
	mui.toast('后退功能已禁用,请使用返回按钮');
	return
}